package com.weixu.fileconver.test;

import cn.hutool.core.util.RuntimeUtil;

import java.io.File;

/**
 * @Author weixu
 * @Date 2025/8/29 下午12:59
 */

public class test {
    public static void main(String[] args) throws Exception {
        ProcessBuilder pb = new ProcessBuilder(
                "C:\\Program Files\\LibreOffice\\program\\soffice.com",
                "--headless",
                "--infilter=writer_pdf_import",
                "--convert-to", "html",
                "H:\\weixu\\file-conver\\test.pdf",
                "--outdir", "H:\\weixu\\file-conver\\temp"
        );

// 重定向日志
        pb.redirectOutput(new File("H:\\weixu\\file-conver\\temp\\log.txt"));
        pb.redirectError(new File("H:\\weixu\\file-conver\\temp\\err.txt"));

        Process process = pb.start();
        int exitCode = process.waitFor();
        System.out.println("Exit Code: " + exitCode);
    }
}
